package com.ky.pro.java.dt.kitchen.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ky.pro.java.dt.common.web.ResultBean;
import com.ky.pro.java.dt.kitchen.entity.KitchenProcess;
import com.ky.pro.java.dt.kitchen.mapper.KitchenProcessMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Kevin Dummy
 * @since 2021-12-26
 */
@Service
public class KitchenProcessServiceImpl extends ServiceImpl<KitchenProcessMapper, KitchenProcess> {

    @Autowired
    KitchenProcessMapper kitchenProcessMapper;

    public ResultBean<Boolean> checkKitchenProcessExistence(long orderNo) {

        Long processCnt = kitchenProcessMapper.selectCount(new QueryWrapper<KitchenProcess>()
                .eq("order_no", orderNo));

        return ResultBean.genResult(processCnt > 0);
    }

    public ResultBean<String> updateKitchenProcessStatus(long orderNo, int status) {
        return kitchenProcessMapper.updateByOrderNo(orderNo, status) > 0 ?
                ResultBean.genResult("更新成功") : ResultBean.genError("更新失败");

    }

}
